package com.sunedai.tiger.web.controller.emp;

import com.sunedai.tiger.dao.system.entity.EmpUsr;
import com.sunedai.tiger.service.system.EmpUsrService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * 登录控制器
 * @author zhaolipeng
 */
@Controller
@RequestMapping("/emp/login")
public class EmpLoginController extends BaseEmpController {

  @Resource
  private EmpUsrService empUsrService;

  @GetMapping
  public ModelAndView login() {
    return new ModelAndView("/emp/login");
  }

  @PostMapping
  @ResponseBody
  public void login(@RequestParam String loginName,
                    @RequestParam String password) {
    EmpUsr empUsr = empUsrService.checkLogin(loginName, password);
    setUsrInfoToSession(empUsr);
  }
}
